﻿#region References
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using System.Reflection;
using LuaInterface;
using JigLibX.Physics;
using JigLibX.Geometry;
using JigLibX.Collision;
using Ness.Engine.GUI;
#endregion

namespace Ness.Engine.Lua
{
    /// <summary>
    /// Allows Lua to be able to modify the map
    /// </summary>
    class LuaMapProxy
    {
        #region Public variables
        public Engine game;
        public LuaParser lua;
        #endregion

        /// <summary>
        /// Initialises the Lua-Map proxy
        /// </summary>
        /// <param name="lua">The main parser class</param>
        /// <param name="_game">The current engine instance</param>
        public LuaMapProxy(LuaParser lua, Engine _game)
        {
            this.lua = lua;
            game = _game;
        }

        #region Lua Functions
        public void CreateLight(LuaInterface.LuaTable position, LuaInterface.LuaTable colour, LuaInterface.LuaTable specular, double power, bool perPixel)
        {
            double[] tbl = new double[position.Values.Count];
            position.Values.CopyTo(tbl, 0);

            double[] col = new double[colour.Values.Count];
            colour.Values.CopyTo(col, 0);

            double[] spec = new double[specular.Values.Count];
            specular.Values.CopyTo(spec, 0);

            Color lightColour = new Color((float)col[0], (float)col[1], (float)col[2]);

            game.AddLightToScene(new Vector3((float)tbl[0], (float)tbl[1], (float)tbl[2]), lightColour, new Color((byte)spec[0], (byte)spec[1], (byte)spec[2]), (float)power, perPixel);
        }
        #endregion


    }
}
